package wire

type Group struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type GroupService interface {
	GetGroup(id string) *Group
}

var _ GroupService = (*groupService)(nil)

type groupService struct {
	db Database
}

func NewGroupService(db Database) GroupService {
	return &groupService{db: db}
}

func (u *groupService) GetGroup(id string) *Group {
	data := u.db.GetById(id)
	return toGroup(data)
}

func toGroup(data map[string]interface{}) *Group {
	u := &Group{
		Id:   data["id"].(string),
		Name: data["name"].(string),
	}

	return u
}
